<?php

namespace app\health\model\healthPro;

use app\health\service\PajkService;
use think\Model;

class TvUserCard extends Model
{
    protected $name = 'tv_user_card';

    protected $connection = 'database.pajk';

    /**
     * 产品包含的服务
     * @param $val
     * @return array|mixed
     */
    public function getContentAttr($val)
    {
        return unserialize($val) ?: [];
    }

    /**
     * 产品包含的服务的列表
     * @param $content
     * @param string $productCode
     * @return array
     */
    public static function getContentList($content, string $productCode = ''): array
    {
        $data = [];
        foreach ($content as $key => $item) {
            $name = '';
            if ($key === 'bgjd') {
                continue;
            }
            if ($key === 'twwz' && ($productCode === 'XQY_YOUXIANG' || $productCode === 'XQY_ZUNXIANG' || $productCode === 'XQY_ZHENXIANG')) {
                $item = '无限制';
            }
            $data[] = PajkService::infoByIden($key, $item, $name);
        }
        return $data;
    }
}